import com.demo.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class GetBeanExample2 {
    public static void main(String[] args) {
        //1.得到容器对象
        ApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
        //2.获取Bean
        UserService userService=context.getBean("user1",UserService.class);
        //3.使用Bean
        userService.sayHi();
    }
}
